﻿using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Unity;

namespace Airborne.ScrumPoker.Module.Developer
{
    public class DeveloperModule : IModule
    {
        private IUnityContainer Container { get; set; }

        public DeveloperModule(IUnityContainer container)
        {
            Container = container;
        }

        #region IModule Members

        public void Initialize()
        {
            RegisterComponents();
            Container.Resolve<Controllers.ITimerController>().Run();
            Container.Resolve<Controllers.IWorkItemController>().Run();
            Container.Resolve<Controllers.ICardsController>().Run();
            Container.Resolve<Controllers.ILogOnController>().Run();
        }

        private void RegisterComponents()
        {
            Container.RegisterType<Views.ITimerView, Views.TimerView>(new ExternallyControlledLifetimeManager());
            Container.RegisterType<Views.ILogOnView, Views.LogOnView>(new ExternallyControlledLifetimeManager());
            Container.RegisterType<Views.IWorkItemDetailView, Views.WorkItemDetailView>(new ExternallyControlledLifetimeManager());
            Container.RegisterType<Views.ICardsView, Views.CardsView>(new ExternallyControlledLifetimeManager());

            Container.RegisterType<Controllers.IWorkItemController, Controllers.WorkItemController>(new ExternallyControlledLifetimeManager());
            Container.RegisterType<Controllers.ICardsController, Controllers.CardsController>(new ExternallyControlledLifetimeManager());
            Container.RegisterType<Controllers.ITimerController, Controllers.TimerController>(new ExternallyControlledLifetimeManager());
            Container.RegisterType<Controllers.ILogOnController, Controllers.LogOnController>(new ExternallyControlledLifetimeManager());

        }

        #endregion
    }
}
